<template>
	<view class="page-container">
		<use-navbar ref="navbar" type="custom" :show="true" :back="false" :bg-color="navbarBgcolor" :title="''">
			<template v-slot:title>
				<view class="tac">
					<text class="fs-34 fwbd ft-white">事项</text>
				</view>
			</template>
			<template v-slot:right>
				<view class="tac trophy" @click='toTrophy'>
					<image src="../../static/icons/icon-trophy.png" class="icon"></image>
				</view>
			</template>
		</use-navbar>
		
		<!-- #ifdef MP-WEIXIN || MP-BAIDU -->
		<web-view :src="unityWebUrl" bindmessage="receiveMessage"></web-view>
		<!-- #endif -->
		<!-- #ifdef H5 -->
		<web-view style="position: fixed;top:0;left: 0;width: 100vw;height: 100vh;" :src="unityWebUrl" full-screen
			ref="unityWindows"></web-view>
		<!-- #endif -->
		<use-tabbar></use-tabbar>
	</view>
</template>

<script setup lang="ts">
	// --组合式 API 模板
	import { ref, inject, onMounted } from 'vue'
	import HttpService from '../../api/index';
	import {
		onLoad,
		onShow,
	} from "@dcloudio/uni-app";

	const globalData = inject('globalData')
	const title = ref("标题")
	const navbarBgcolor = ref('')
	const unityWebUrl=ref('http://localhost:8067/index.html?v=1.0.2')
	// onLoad 接受 A 页面传递的参数
	onLoad((option) => {
		console.log("B 页面 onLoad:", option); //B 页面 onLoad: {id: '1', name: 'uniapp'}
	});

	onShow(() => {
		console.log("B 页面 onShow");
	});
	onMounted(() => {
		console.log(globalData.message, globalData.config)
	})
	const loadData = async () => {
		const httpService = new HttpService('https://example.com/api')

		try {
			const userData = await httpService.request({
				url: '/users/1',
				method: 'GET'
			})
			console.log(userData)
		} catch (error) {
			console.error(error)
		}
	}
	const toTrophy = () => {

	}
</script>

<style lang="less" scoped>
	.trophy {
		width: 35px;
		height: 35px;
	}
	
	.trophy .icon {
		width: 100%;
		height: 100%;
	}
	
</style>